package com.wander.common;

import java.util.List;

/**
 * Created by zhaowentong on 2017/6/2.
 */
public class BaseService<M, QM extends BaseModel> extends BComponent implements IBaseService<M, QM> {
    private BaseDAO<M, QM> dao;

    public BaseService() {
    }

    public void setDAO(BaseDAO<M, QM> dao) {
        this.dao = dao;
    }

    public boolean create(M m) {
        return this.dao.create(m) == 1;
    }

    public boolean update(M m) {
        return this.dao.update(m) == 1;
    }

    public boolean delete(int id) {
        return this.dao.delete(id) == 1;
    }

    public M getById(int id) {
        return this.dao.getById(id);
    }

    public Page queryByPage(QM qm) {
        List list = this.dao.queryByPage(qm);
        qm.getPage().setResult(list);
        return qm.getPage();
    }
}
